/**
 *
 */
import OpenApi;
import OpenApi.OpenApiUtil;

extends OpenApi;


init(config: OpenApiUtil.Config){
  super(config);
  @signatureAlgorithm = 'v2';
  @endpointRule = 'regional';
  @endpointMap = {
    'cn-beijing' = 'cn-beijing.fnf.aliyuncs.com',
    'cn-hangzhou' = 'cn-hangzhou.fnf.aliyuncs.com',
    'cn-shanghai' = 'cn-shanghai.fnf.aliyuncs.com',
    'cn-shenzhen' = 'cn-shenzhen.fnf.aliyuncs.com',
  };

  checkConfig(config);
  @endpoint = getEndpoint('fnf', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!$isNull(endpoint)) {
    return endpoint;
  }
  
  if (!$isNull(endpointMap) && !$isNull(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return OpenApiUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model CreateFlowRequest {
  definition?: string(name='Definition', description='The definition of the workflow. The definition must comply with the flow definition language (FDL) syntax. Considering compatibility, the system supports two flow definition specifications.

>  In the preceding flow definition example, Name:my_flow_name is the workflow name, which must be consistent with the input parameter Name

This parameter is required.', example='version:&nbsp;v1.0<br/>type:&nbsp;flow<br/>steps:<br/>&nbsp;-&nbsp;type:&nbsp;pass<br/>&nbsp;name:&nbsp;mypass'),
  description?: string(name='Description', description='The description of the flow.

This parameter is required.', example='test flow'),
  executionMode?: string(name='ExecutionMode', description='The execution mode. Valid values: Express and Standard. Considering compatibility, an empty string is equivalent to the Standard execution mode.', example='Standard'),
  externalStorageLocation?: string(name='ExternalStorageLocation', description='The path of the external storage.', example='/path'),
  name?: string(name='Name', description='The name of the flow. The name is unique within the same region and cannot be modified after the flow is created. Set this parameter based on the following rules:

*   The name can contain letters, digits, underscores (_), and hyphens (-).
*   The name must start with a letter or an underscore (_).
*   The name is case-sensitive.
*   The name must be 1 to 128 characters in length.

This parameter is required.', example='flow'),
  roleArn?: string(name='RoleArn', description='The Alibaba Cloud resource name (ARN) of the authorized role on which the execution of the flow relies. During the execution of the flow, CloudFlow assumes the role to call API operations of relevant services.', example='acs:ram:${region}:${accountID}:${role}'),
  type?: string(name='Type', description='The type of the flow. Set this parameter to **FDL**.

This parameter is required.', example='FDL'),
}

model CreateFlowResponseBody = {
  createdTime?: string(name='CreatedTime', description='The time when the flow was created.', example='2019-01-01T01:01:01.001Z'),
  definition?: string(name='Definition', description='Considering compatibility, the system supports two flow definition specifications.', example='version: v1.0\\\\ntype: flow\\\\nname: test\\\\nsteps:\\\\n - type: pass\\\\n name: mypass'),
  description?: string(name='Description', description='The description of the flow.', example='test flow'),
  executionMode?: string(name='ExecutionMode', description='The execution mode. Valid values: Express and Standard. Considering compatibility, an empty string is equivalent to the Standard execution mode.', example='Standard'),
  id?: string(name='Id', description='The unique ID of the flow.', example='e589e092-e2c0-4dee-b306-3574ddfdddf5****'),
  lastModifiedTime?: string(name='LastModifiedTime', description='The time when the flow was last modified.', example='2019-01-01T01:01:01.001Z'),
  name?: string(name='Name', description='The name of the flow.', example='flow'),
  requestId?: string(name='RequestId', description='The request ID. Each time an `HTTP status code` is returned, Serverless Workflow returns a value for the parameter.', example='testRequestID'),
  roleArn?: string(name='RoleArn', description='The Alibaba Cloud resource name (ARN) of the authorized role on which the execution of the flow relies. During the execution of the flow, CloudFlow assumes the role to call API operations of relevant services.', example='acs:ram:${region}:${accountID}:${role}'),
  type?: string(name='Type', description='The type of the flow.

Valid value:

*   FDL

    <!-- -->

    <!-- -->

    <!-- -->', example='FDL'),
}

model CreateFlowResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateFlowResponseBody(name='body'),
}

/**
 * @summary Creates a flow.
 *
 * @description ## [](#)Usage notes
 * *   The number of flows that each user can create is restricted by resources. For more information, see [Limits](https://help.aliyun.com/document_detail/122093.html). If you want to create more flows, submit a ticket.
 * *   At the user level, flows are distinguished by name. The name of a flow within one account must be unique.
 *
 * @param request CreateFlowRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateFlowResponse
 */
async function createFlowWithOptions(request: CreateFlowRequest, runtime: $RuntimeOptions): CreateFlowResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.definition)) {
    body['Definition'] = request.definition;
  }
  if (!$isNull(request.description)) {
    body['Description'] = request.description;
  }
  if (!$isNull(request.executionMode)) {
    body['ExecutionMode'] = request.executionMode;
  }
  if (!$isNull(request.externalStorageLocation)) {
    body['ExternalStorageLocation'] = request.externalStorageLocation;
  }
  if (!$isNull(request.name)) {
    body['Name'] = request.name;
  }
  if (!$isNull(request.roleArn)) {
    body['RoleArn'] = request.roleArn;
  }
  if (!$isNull(request.type)) {
    body['Type'] = request.type;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'CreateFlow',
    version = '2019-03-15',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Creates a flow.
 *
 * @description ## [](#)Usage notes
 * *   The number of flows that each user can create is restricted by resources. For more information, see [Limits](https://help.aliyun.com/document_detail/122093.html). If you want to create more flows, submit a ticket.
 * *   At the user level, flows are distinguished by name. The name of a flow within one account must be unique.
 *
 * @param request CreateFlowRequest
 * @return CreateFlowResponse
 */
async function createFlow(request: CreateFlowRequest): CreateFlowResponse {
  var runtime = new $RuntimeOptions{};
  return createFlowWithOptions(request, runtime);
}

model CreateScheduleRequest {
  cronExpression?: string(name='CronExpression', description='The CRON expression.

This parameter is required.', example='0 * * * * *'),
  description?: string(name='Description', description='The description of the time-based schedule.', example='test description'),
  enable?: boolean(name='Enable', description='Specifies whether to enable the time-based schedule. Valid values:

*   **true**
*   **false**', example='true'),
  flowName?: string(name='FlowName', description='The name of the workflow that is associated with the time-based schedule.

This parameter is required.', example='flow'),
  payload?: string(name='Payload', description='The trigger message of the time-based schedule. Specify the value in the JSON format.', example='{"key": "value"}'),
  scheduleName?: string(name='ScheduleName', description='The name of the time-based schedule. The name must meet the following conventions:

*   The name can contain letters, digits, underscores (_), and hyphens (-).
*   The name must start with a letter or an underscore (_).
*   It is case-sensitive.
*   The name must be 1 to 128 characters in length.

This parameter is required.', example='testScheduleName'),
  signatureVersion?: string(name='SignatureVersion'),
}

model CreateScheduleResponseBody = {
  createdTime?: string(name='CreatedTime', description='The time when the time-based schedule was created.', example='2020-01-01T01:01:01.001Z'),
  cronExpression?: string(name='CronExpression', description='The CRON expression.', example='0 * * * * *'),
  description?: string(name='Description', description='The description of the time-based schedule.', example='test description'),
  enable?: boolean(name='Enable', description='Indicates whether the time-based schedule is enabled.', example='true'),
  lastModifiedTime?: string(name='LastModifiedTime', description='The time when the time-based schedule was last modified.', example='2020-01-01T01:01:01.001Z'),
  payload?: string(name='Payload', description='The trigger message of the time-based schedule.', example='{"key": "value"}'),
  requestId?: string(name='RequestId', description='The request ID.', example='testRequestId'),
  scheduleId?: string(name='ScheduleId', description='The ID of the time-based schedule.', example='testScheduleId'),
  scheduleName?: string(name='ScheduleName', description='The name of the time-based schedule.', example='testScheduleName'),
}

model CreateScheduleResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateScheduleResponseBody(name='body'),
}

/**
 * @summary Creates a time-based schedule.
 *
 * @param request CreateScheduleRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateScheduleResponse
 */
async function createScheduleWithOptions(request: CreateScheduleRequest, runtime: $RuntimeOptions): CreateScheduleResponse {
  request.validate();
  var query = {};
  if (!$isNull(request.signatureVersion)) {
    query['SignatureVersion'] = request.signatureVersion;
  }
  var body : map[string]any = {};
  if (!$isNull(request.cronExpression)) {
    body['CronExpression'] = request.cronExpression;
  }
  if (!$isNull(request.description)) {
    body['Description'] = request.description;
  }
  if (!$isNull(request.enable)) {
    body['Enable'] = request.enable;
  }
  if (!$isNull(request.flowName)) {
    body['FlowName'] = request.flowName;
  }
  if (!$isNull(request.payload)) {
    body['Payload'] = request.payload;
  }
  if (!$isNull(request.scheduleName)) {
    body['ScheduleName'] = request.scheduleName;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'CreateSchedule',
    version = '2019-03-15',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Creates a time-based schedule.
 *
 * @param request CreateScheduleRequest
 * @return CreateScheduleResponse
 */
async function createSchedule(request: CreateScheduleRequest): CreateScheduleResponse {
  var runtime = new $RuntimeOptions{};
  return createScheduleWithOptions(request, runtime);
}

model DeleteFlowRequest {
  name?: string(name='Name', description='This parameter is required.'),
}

model DeleteFlowResponseBody = {
  requestId?: string(name='RequestId', description='The request ID.', example='testRequestId'),
}

model DeleteFlowResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DeleteFlowResponseBody(name='body'),
}

/**
 * @summary Deletes an existing flow.
 *
 * @description ## [](#)Usage notes
 * A delete operation is asynchronous. If this operation is successful, the system returns a successful response. If an existing flow is pending to be deleted, a new flow of the same name will not be affected by the existing one. After you delete a flow, you cannot query its historical executions. All executions in progress will stop after their most recent steps are complete.
 *
 * @param request DeleteFlowRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DeleteFlowResponse
 */
async function deleteFlowWithOptions(request: DeleteFlowRequest, runtime: $RuntimeOptions): DeleteFlowResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.name)) {
    body['Name'] = request.name;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'DeleteFlow',
    version = '2019-03-15',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Deletes an existing flow.
 *
 * @description ## [](#)Usage notes
 * A delete operation is asynchronous. If this operation is successful, the system returns a successful response. If an existing flow is pending to be deleted, a new flow of the same name will not be affected by the existing one. After you delete a flow, you cannot query its historical executions. All executions in progress will stop after their most recent steps are complete.
 *
 * @param request DeleteFlowRequest
 * @return DeleteFlowResponse
 */
async function deleteFlow(request: DeleteFlowRequest): DeleteFlowResponse {
  var runtime = new $RuntimeOptions{};
  return deleteFlowWithOptions(request, runtime);
}

model DeleteScheduleRequest {
  flowName?: string(name='FlowName', description='This parameter is required.'),
  scheduleName?: string(name='ScheduleName', description='This parameter is required.'),
}

model DeleteScheduleResponseBody = {
  requestId?: string(name='RequestId', description='The request ID.', example='testRequestId'),
}

model DeleteScheduleResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DeleteScheduleResponseBody(name='body'),
}

/**
 * @summary Deletes a time-based scheduling task.
 *
 * @param request DeleteScheduleRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DeleteScheduleResponse
 */
async function deleteScheduleWithOptions(request: DeleteScheduleRequest, runtime: $RuntimeOptions): DeleteScheduleResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.flowName)) {
    body['FlowName'] = request.flowName;
  }
  if (!$isNull(request.scheduleName)) {
    body['ScheduleName'] = request.scheduleName;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'DeleteSchedule',
    version = '2019-03-15',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Deletes a time-based scheduling task.
 *
 * @param request DeleteScheduleRequest
 * @return DeleteScheduleResponse
 */
async function deleteSchedule(request: DeleteScheduleRequest): DeleteScheduleResponse {
  var runtime = new $RuntimeOptions{};
  return deleteScheduleWithOptions(request, runtime);
}

model DescribeExecutionRequest {
  executionName?: string(name='ExecutionName', description='The name of the execution.

This parameter is required.', example='exec'),
  flowName?: string(name='FlowName', description='The name of the workflow.

This parameter is required.', example='flow'),
  waitTimeSeconds?: int32(name='WaitTimeSeconds', description='The maximum period of time for long polling waits. Valid values: 0 to 60. Unit: seconds. Configure this parameter based on the following rules:

*   If the value is 0, the system immediately returns the current execution status.
*   If the value is greater than 0, the long polling request waits until the execution ends or the specified period elapses.', example='20'),
}

model DescribeExecutionResponseBody = {
  flowDefinition?: string(name='FlowDefinition', description='The definition of the flow.', example='version: v1.0\\\\ntype: flow\\\\nname: test\\\\nsteps:\\\\n - type: pass\\\\n name: mypass'),
  flowName?: string(name='FlowName', description='The name of the flow.', example='flow'),
  input?: string(name='Input', description='The input of the execution, which is in the JSON format.', example='{"key":"value"}'),
  name?: string(name='Name', description='The name of the execution.', example='exec'),
  output?: string(name='Output', description='The execution result, which is in the JSON format.', example='{"key":"value"}'),
  requestId?: string(name='RequestId', description='The request ID.', example='testRequestId'),
  startedTime?: string(name='StartedTime', description='The time when the execution started.', example='2019-01-01T01:01:01.001Z'),
  status?: string(name='Status', description='The execution status. Valid values:

*   **Starting**
*   **Running**
*   **Stopped**
*   **Succeeded**
*   **Failed**
*   **TimedOut**', example='Succeeded'),
  stoppedTime?: string(name='StoppedTime', description='The time when the execution stopped.', example='2019-01-01T01:01:01.001Z'),
}

model DescribeExecutionResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeExecutionResponseBody(name='body'),
}

/**
 * @summary Queries an execution in a flow. The long polling mode is supported. The maximum waiting period for long polling depends on the value of the WaitTimeSeconds parameter.
 *
 * @param request DescribeExecutionRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeExecutionResponse
 */
async function describeExecutionWithOptions(request: DescribeExecutionRequest, runtime: $RuntimeOptions): DescribeExecutionResponse {
  request.validate();
  var query = OpenApiUtil.query(request.toMap());
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'DescribeExecution',
    version = '2019-03-15',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'GET',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Queries an execution in a flow. The long polling mode is supported. The maximum waiting period for long polling depends on the value of the WaitTimeSeconds parameter.
 *
 * @param request DescribeExecutionRequest
 * @return DescribeExecutionResponse
 */
async function describeExecution(request: DescribeExecutionRequest): DescribeExecutionResponse {
  var runtime = new $RuntimeOptions{};
  return describeExecutionWithOptions(request, runtime);
}

model DescribeFlowRequest {
  name?: string(name='Name', description='The name of the flow.

This parameter is required.', example='flow'),
}

model DescribeFlowResponseBody = {
  createdTime?: string(name='CreatedTime', description='The time when the flow was created.', example='2019-01-01T01:01:01.001Z'),
  definition?: string(name='Definition', description='The flow definition, which follows the flow definition language (FDL) syntax standard. Considering compatibility, the system supports the two flow definition specifications.', example='version: v1.0\\\\ntype: flow\\\\nname: test\\\\nsteps:\\\\n - type: pass\\\\n name: mypass'),
  description?: string(name='Description', description='The description of the flow.', example='test flow'),
  executionMode?: string(name='ExecutionMode', description='The execution mode or the enumeration type. Valid values: Express and Standard. A value of Standard indicates an empty string.', example='Standard'),
  id?: string(name='Id', description='The unique ID of the flow.', example='e589e092-e2c0-4dee-b306-3574ddfdddf5****'),
  lastModifiedTime?: string(name='LastModifiedTime', description='The time when the flow was last modified.', example='2019-01-01T01:01:01.001Z'),
  name?: string(name='Name', description='The name of the flow.', example='flow'),
  requestId?: string(name='RequestId', description='The request ID.', example='testRequestId'),
  roleArn?: string(name='RoleArn', description='The Alibaba Cloud resource name (ARN) of the authorized role on which the execution of the flow relies. During the execution of the flow, CloudFlow assumes the role to call API operations of relevant services.', example='acs:ram::${accountID}:${role}'),
  type?: string(name='Type', description='The type of the workflow.', example='FDL'),
}

model DescribeFlowResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeFlowResponseBody(name='body'),
}

/**
 * @summary Queries the information about a flow.
 *
 * @param request DescribeFlowRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeFlowResponse
 */
async function describeFlowWithOptions(request: DescribeFlowRequest, runtime: $RuntimeOptions): DescribeFlowResponse {
  request.validate();
  var query = OpenApiUtil.query(request.toMap());
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'DescribeFlow',
    version = '2019-03-15',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'GET',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Queries the information about a flow.
 *
 * @param request DescribeFlowRequest
 * @return DescribeFlowResponse
 */
async function describeFlow(request: DescribeFlowRequest): DescribeFlowResponse {
  var runtime = new $RuntimeOptions{};
  return describeFlowWithOptions(request, runtime);
}

model DescribeRegionsResponseBody = {
  regions?: {
    region?: [ 
      {
        localName?: string(name='LocalName'),
        regionEndpoint?: string(name='RegionEndpoint', example='cn-qingdao.fnf.aliyuncs.com'),
        regionId?: string(name='RegionId', example='cn-qingdao'),
      }
    ](name='Region'),
  }(name='Regions'),
  requestId?: string(name='RequestId', example='0aa3f793-6e5f-8472-c7a2-70d2b84c04ac'),
}

model DescribeRegionsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeRegionsResponseBody(name='body'),
}

/**
 * @summary 查询地域信息列表
 *
 * @param request DescribeRegionsRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeRegionsResponse
 */
async function describeRegionsWithOptions(runtime: $RuntimeOptions): DescribeRegionsResponse {
  var req = new OpenApiUtil.OpenApiRequest{};
  var params = new OpenApiUtil.Params{
    action = 'DescribeRegions',
    version = '2019-03-15',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 查询地域信息列表
 *
 * @return DescribeRegionsResponse
 */
async function describeRegions(): DescribeRegionsResponse {
  var runtime = new $RuntimeOptions{};
  return describeRegionsWithOptions(runtime);
}

model DescribeScheduleRequest {
  flowName?: string(name='FlowName', description='The name of the flow that is associated with the time-based schedule. The name must be unique within the region and cannot be modified after the time-based schedule is created. The name must meet the following conventions:

*   The name can contain letters, digits, underscores (_), and hyphens (-).
*   The name must start with a letter or an underscore (_).
*   The name is case-sensitive.
*   The name must be 1 to 128 characters in length.

This parameter is required.', example='testFlowName'),
  scheduleName?: string(name='ScheduleName', description='The name of the time-based schedule. The name must meet the following conventions:

*   The name can contain letters, digits, underscores (_), and hyphens (-).
*   The name must start with a letter or an underscore (_).
*   The name is case-sensitive.
*   The name must be 1 to 128 characters in length.

This parameter is required.', example='testScheduleName'),
}

model DescribeScheduleResponseBody = {
  createdTime?: string(name='CreatedTime', description='The time when the time-based schedule was created.', example='2020-01-01T01:01:01.001Z'),
  cronExpression?: string(name='CronExpression', description='The CRON expression.', example='0 * * * * *'),
  description?: string(name='Description', description='The description of the time-based schedule.', example='test description'),
  enable?: boolean(name='Enable', description='Indicates whether the time-based schedule is enabled. Valid values:

*   **true**
*   **false**', example='true'),
  lastModifiedTime?: string(name='LastModifiedTime', description='The time when the time-based schedule was last modified.', example='2020-01-01T01:01:01.001Z'),
  payload?: string(name='Payload', description='The trigger message of the time-based schedule.', example='{"key": "value"}'),
  requestId?: string(name='RequestId', description='The request ID.', example='testRequestId'),
  scheduleId?: string(name='ScheduleId', description='The ID of the time-based schedule.', example='testScheduleId'),
  scheduleName?: string(name='ScheduleName', description='The name of the time-based schedule.', example='testScheduleName'),
}

model DescribeScheduleResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeScheduleResponseBody(name='body'),
}

/**
 * @summary Queries the detailed information about a time-based schedule.
 *
 * @param request DescribeScheduleRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeScheduleResponse
 */
async function describeScheduleWithOptions(request: DescribeScheduleRequest, runtime: $RuntimeOptions): DescribeScheduleResponse {
  request.validate();
  var query = OpenApiUtil.query(request.toMap());
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'DescribeSchedule',
    version = '2019-03-15',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'GET',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Queries the detailed information about a time-based schedule.
 *
 * @param request DescribeScheduleRequest
 * @return DescribeScheduleResponse
 */
async function describeSchedule(request: DescribeScheduleRequest): DescribeScheduleResponse {
  var runtime = new $RuntimeOptions{};
  return describeScheduleWithOptions(request, runtime);
}

model GetExecutionHistoryRequest {
  executionName?: string(name='ExecutionName', description='The name of the execution.

This parameter is required.', example='exec'),
  flowName?: string(name='FlowName', description='The name of the workflow.

This parameter is required.', example='flow'),
  limit?: int32(name='Limit', description='The number of workflows that you want to query. Valid values: 1-999. Default value: 60.', example='1'),
  nextToken?: string(name='NextToken', description='The name of the event to start the query. You can obtain the value from the response data.', example='flow_xxx'),
}

model GetExecutionHistoryResponseBody = {
  events?: [ 
    {
      eventDetail?: string(name='EventDetail', description='The details about the execution step.', example='{}'),
      eventId?: long(name='EventId', description='The ID of the execution step.', example='2'),
      scheduleEventId?: long(name='ScheduleEventId', description='The ID of the scheduling step.', example='1'),
      stepName?: string(name='StepName', description='The name of the execution step.', example='passStep'),
      time?: string(name='Time', description='The time when the event was updated.', example='2019-01-01T01:01:01.001Z'),
      type?: string(name='Type', description='The type of the execution step. Valid values:

*   **StepEntered**
*   **StepStarted**
*   **StepSucceeded**
*   **StepFailed**
*   **StepExited**
*   **BranchEntered**
*   **BranchExited**
*   **IterationEntered**
*   **IterationExited**
*   **TaskScheduled**
*   **TaskStarted**
*   **TaskSubmitted**
*   **TaskSubmitFailed**
*   **TaskSucceeded**
*   **TaskFailed**
*   **TaskTimedOut**
*   **ExecutionStarted**
*   **ExecutionStopped**
*   **ExecutionSucceeded**
*   **ExecutionFailed**
*   **ExecutionTimedOut**', example='TaskSucceeded'),
    }
  ](name='Events', description='The events.'),
  nextToken?: string(name='NextToken', description='You do not need to specify this parameter for the first request. The returned value of **ScheduleEventId** is used as the token for the next query. No value is returned for the last query.', example='3'),
  requestId?: string(name='RequestId', description='The request ID.', example='testRequestId'),
}

model GetExecutionHistoryResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetExecutionHistoryResponseBody(name='body'),
}

/**
 * @summary Queries the details about each step in an execution process.
 *
 * @param request GetExecutionHistoryRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetExecutionHistoryResponse
 */
async function getExecutionHistoryWithOptions(request: GetExecutionHistoryRequest, runtime: $RuntimeOptions): GetExecutionHistoryResponse {
  request.validate();
  var query = OpenApiUtil.query(request.toMap());
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'GetExecutionHistory',
    version = '2019-03-15',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'GET',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Queries the details about each step in an execution process.
 *
 * @param request GetExecutionHistoryRequest
 * @return GetExecutionHistoryResponse
 */
async function getExecutionHistory(request: GetExecutionHistoryRequest): GetExecutionHistoryResponse {
  var runtime = new $RuntimeOptions{};
  return getExecutionHistoryWithOptions(request, runtime);
}

model ListExecutionsRequest {
  executionNamePrefix?: string(name='ExecutionNamePrefix', description='The name prefix of the execution.', example='run'),
  flowName?: string(name='FlowName', description='The name of the flow. The name must be unique within the region and cannot be modified after the flow is created. The name must meet the following conventions:

*   The name can contain letters, digits, underscores (_), and hyphens (-).
*   The name must start with a letter or an underscore (_).
*   The name is case-sensitive.
*   The name must be 1 to 128 characters in length.

This parameter is required.', example='flow'),
  limit?: int32(name='Limit', description='The number of executions that you want to query. Valid values: 1-99. Default value: 60.', example='1'),
  metadataOnly?: boolean(name='MetadataOnly'),
  nextToken?: string(name='NextToken', description='The name of the execution to start the query. You can obtain the value from the response data. You do not need to specify this parameter for the first request.', example='flow_xxx'),
  startedTimeBegin?: string(name='StartedTimeBegin', description='The beginning of the time range to query executions. Specify the value in the UTC RFC3339 format.', example='2020-12-02T02:39:20.402Z'),
  startedTimeEnd?: string(name='StartedTimeEnd', description='The end of the time range to query executions. Specify the value in the UTC RFC3339 format.', example='2020-12-02T02:23:54.817Z'),
  status?: string(name='Status', description='The status of the execution that you want to filter. Valid values:

*   **Starting**
*   **Running**
*   **Stopped**
*   **Succeeded**
*   **Failed**
*   **TimedOut**', example='Succeeded'),
}

model ListExecutionsResponseBody = {
  executions?: [ 
    {
      flowDefinition?: string(name='FlowDefinition', description='The definition of the flow.', example='version: v1.0\\\\ntype: flow\\\\nname: test\\\\nsteps:\\\\n  - type: pass\\\\n    name: mypass'),
      flowName?: string(name='FlowName', description='The name of the flow.', example='flow'),
      input?: string(name='Input', description='The input of the execution, which is in the JSON format.', example='{"key":"value"}'),
      name?: string(name='Name', description='The name of the execution.', example='exec'),
      output?: string(name='Output', description='The output of the execution, which is in the JSON format', example='{"key":"value"}'),
      startedTime?: string(name='StartedTime', description='The time when the execution started.', example='2019-01-01T01:01:01.001Z'),
      status?: string(name='Status', description='The status of the execution.', example='Succeeded'),
      stoppedTime?: string(name='StoppedTime', description='The time when the execution stopped.', example='2019-01-01T01:01:01.001Z'),
    }
  ](name='Executions', description='The information about executions.'),
  nextToken?: string(name='NextToken', description='The start key for the next query. This parameter is not returned if this is the last query.

>  This parameter may not be displayed in the response because no next page exists.', example='exec2'),
  requestId?: string(name='RequestId', description='The request ID.', example='testRequestId'),
}

model ListExecutionsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListExecutionsResponseBody(name='body'),
}

/**
 * @summary Queries all historical executions of a flow.
 *
 * @description ## [](#)Usage notes
 * After you delete a flow, you cannot query its historical executions, even if you create a flow of the same name.
 *
 * @param request ListExecutionsRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListExecutionsResponse
 */
async function listExecutionsWithOptions(request: ListExecutionsRequest, runtime: $RuntimeOptions): ListExecutionsResponse {
  request.validate();
  var query = OpenApiUtil.query(request.toMap());
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'ListExecutions',
    version = '2019-03-15',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'GET',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Queries all historical executions of a flow.
 *
 * @description ## [](#)Usage notes
 * After you delete a flow, you cannot query its historical executions, even if you create a flow of the same name.
 *
 * @param request ListExecutionsRequest
 * @return ListExecutionsResponse
 */
async function listExecutions(request: ListExecutionsRequest): ListExecutionsResponse {
  var runtime = new $RuntimeOptions{};
  return listExecutionsWithOptions(request, runtime);
}

model ListFlowsRequest {
  limit?: int32(name='Limit', description='The number of workflows that you want to query. Valid values: 1 - 999. Default value: 60.', example='1'),
  nextToken?: string(name='NextToken', description='The token to start the query.', example='flow_nextxxx'),
}

model ListFlowsResponseBody = {
  flows?: [ 
    {
      createdTime?: string(name='CreatedTime', description='The time when the flow was created.', example='2019-01-01T01:01:01.001Z'),
      definition?: string(name='Definition', description='The definition of the flow. The definition must comply with the Flow Definition Language (FDL) syntax.', example='version: v1.0\\\\ntype: flow\\\\nname: test\\\\nsteps:\\\\n - type: pass\\\\n name: mypass'),
      description?: string(name='Description', description='The description of the flow.', example='test flow'),
      executionMode?: string(name='ExecutionMode', description='The execution mode or the enumeration type. Valid values: Express and Standard. A value of Standard indicates an empty string.', example='Standard'),
      id?: string(name='Id', description='The unique ID of the flow.', example='e589e092-e2c0-4dee-b306-3574ddf5****'),
      lastModifiedTime?: string(name='LastModifiedTime', description='The time when the flow was last modified.', example='2019-01-01T01:01:01.001Z'),
      name?: string(name='Name', description='The name of the flow.', example='flow'),
      roleArn?: string(name='RoleArn', description='The Alibaba Cloud resource name (ARN) of the specified Resource Access Management (RAM) role that Serverless Workflow assumes to invoke resources when the flow is executed.', example='acs:ram::${accountID}:${role}'),
      type?: string(name='Type', description='The type of the flow.', example='FDL'),
    }
  ](name='Flows', description='The details of flows.'),
  nextToken?: string(name='NextToken', description='The start key for the next query. This parameter is not returned if all results have been returned.', example='flow_nextxxx'),
  requestId?: string(name='RequestId', description='The request ID.', example='testRequestId'),
}

model ListFlowsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListFlowsResponseBody(name='body'),
}

/**
 * @summary Queries a list of flows.
 *
 * @param request ListFlowsRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListFlowsResponse
 */
async function listFlowsWithOptions(request: ListFlowsRequest, runtime: $RuntimeOptions): ListFlowsResponse {
  request.validate();
  var query = OpenApiUtil.query(request.toMap());
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'ListFlows',
    version = '2019-03-15',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'GET',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Queries a list of flows.
 *
 * @param request ListFlowsRequest
 * @return ListFlowsResponse
 */
async function listFlows(request: ListFlowsRequest): ListFlowsResponse {
  var runtime = new $RuntimeOptions{};
  return listFlowsWithOptions(request, runtime);
}

model ListSchedulesRequest {
  flowName?: string(name='FlowName', description='The name of the flow that is associated with the time-based schedules. The name is unique within the region and cannot be modified after the flow is created. The name must meet the following conventions:

*   The name can contain letters, digits, underscores (_), and hyphens (-).
*   The name must start with a letter or an underscore (_).
*   The name is case-sensitive.
*   The name must be 1 to 128 characters in length.

This parameter is required.', example='testFlowName'),
  limit?: int32(name='Limit', description='The number of schedules to be queried. Valid values: 1 to 1000.', example='1'),
  nextToken?: string(name='NextToken', description='For the first query, you do not need to specify this parameter. The system uses the value of the **FlowName** parameter as the value of the **NextToken** parameter. When the query ends, no value is returned for this parameter.', example='testNextToken'),
}

model ListSchedulesResponseBody = {
  nextToken?: string(name='NextToken', description='The token for the next query.', example='testNextToken'),
  requestId?: string(name='RequestId', description='The request ID.', example='testRequestId'),
  schedules?: [ 
    {
      createdTime?: string(name='CreatedTime', description='The time when the time-based schedule was created.', example='2020-01-01T01:01:01.001Z'),
      cronExpression?: string(name='CronExpression', description='The cron expression of the scheduled task.', example='0 * * * * *'),
      description?: string(name='Description', description='The description of the time-based schedule.', example='test description'),
      enable?: boolean(name='Enable', description='Indicates whether the time-based schedule is enabled. Valid values:

*   **true**
*   **false**', example='true'),
      lastModifiedTime?: string(name='LastModifiedTime', description='The time when the time-based schedule was last modified.', example='2020-01-01T01:01:01.001Z'),
      payload?: string(name='Payload', description='The trigger message of the time-based schedule.', example='{"key": "value"}'),
      scheduleId?: string(name='ScheduleId', description='The ID of the time-based schedule.', example='testScheduleId'),
      scheduleName?: string(name='ScheduleName', description='The name of the time-based schedule.', example='testScheduleName'),
    }
  ](name='Schedules', description='The time-based schedules that are queried.'),
}

model ListSchedulesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListSchedulesResponseBody(name='body'),
}

/**
 * @summary Queries time-based schedules in a flow.
 *
 * @param request ListSchedulesRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListSchedulesResponse
 */
async function listSchedulesWithOptions(request: ListSchedulesRequest, runtime: $RuntimeOptions): ListSchedulesResponse {
  request.validate();
  var query = OpenApiUtil.query(request.toMap());
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'ListSchedules',
    version = '2019-03-15',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'GET',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Queries time-based schedules in a flow.
 *
 * @param request ListSchedulesRequest
 * @return ListSchedulesResponse
 */
async function listSchedules(request: ListSchedulesRequest): ListSchedulesResponse {
  var runtime = new $RuntimeOptions{};
  return listSchedulesWithOptions(request, runtime);
}

model ReportTaskFailedRequest {
  cause?: string(name='Cause', description='The cause of the failure. The value must be 1 to 4,096 characters in length.', example='emptyString'),
  error?: string(name='Error', description='The error code for the failed task. The error code must be 1 to 128 characters in length.

This parameter is required.', example='nill'),
  taskToken?: string(name='TaskToken', description='The token of the task whose execution you want to report. The task token is passed to the called service, such as Message Service (MNS) or Function Compute. For MNS, the value of this parameter can be obtained from a message. For Function Compute, the value of this parameter can be obtained from an event. For more information, see [Service integration modes](https://help.aliyun.com/document_detail/2592915.html).

This parameter is required.', example='emptyString'),
}

model ReportTaskFailedResponseBody = {
  eventId?: long(name='EventId', description='The ID of the event.', example='1'),
  requestId?: string(name='RequestId', description='The request ID.', example='testRequestId'),
}

model ReportTaskFailedResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ReportTaskFailedResponseBody(name='body'),
}

/**
 * @summary Reports a failed task.
 *
 * @description ## [](#)Usage notes
 * In the previous service (Serverless Workflow), the task step that ReportTaskFailed is used to call back `pattern: waitForCallback` indicates that the current task fails to be executed.
 * In the new service (CloudFlow), the task step that ReportTaskFailed is used to call back `TaskMode: WaitForCustomCallback` indicates that the current task fails to be executed.
 *
 * @param request ReportTaskFailedRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ReportTaskFailedResponse
 */
async function reportTaskFailedWithOptions(request: ReportTaskFailedRequest, runtime: $RuntimeOptions): ReportTaskFailedResponse {
  request.validate();
  var query = {};
  if (!$isNull(request.taskToken)) {
    query['TaskToken'] = request.taskToken;
  }
  var body : map[string]any = {};
  if (!$isNull(request.cause)) {
    body['Cause'] = request.cause;
  }
  if (!$isNull(request.error)) {
    body['Error'] = request.error;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'ReportTaskFailed',
    version = '2019-03-15',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Reports a failed task.
 *
 * @description ## [](#)Usage notes
 * In the previous service (Serverless Workflow), the task step that ReportTaskFailed is used to call back `pattern: waitForCallback` indicates that the current task fails to be executed.
 * In the new service (CloudFlow), the task step that ReportTaskFailed is used to call back `TaskMode: WaitForCustomCallback` indicates that the current task fails to be executed.
 *
 * @param request ReportTaskFailedRequest
 * @return ReportTaskFailedResponse
 */
async function reportTaskFailed(request: ReportTaskFailedRequest): ReportTaskFailedResponse {
  var runtime = new $RuntimeOptions{};
  return reportTaskFailedWithOptions(request, runtime);
}

model ReportTaskSucceededRequest {
  output?: string(name='Output', description='The output information of the task whose execution success you want to report.

This parameter is required.', example='{"key":"value"}'),
  taskToken?: string(name='TaskToken', description='The token of the task whose execution you want to report. The task token is passed to the called service, such as Message Service (MNS) or Function Compute. For MNS, the value of this parameter can be obtained from a message. For Function Compute, the value of this parameter can be obtained from an event. For more information, see [Service integration modes](https://help.aliyun.com/document_detail/2592915.html).

This parameter is required.', example='emptyString'),
}

model ReportTaskSucceededResponseBody = {
  eventId?: long(name='EventId', description='The ID of the event.', example='1'),
  requestId?: string(name='RequestId', description='The request ID.', example='testRequestId'),
}

model ReportTaskSucceededResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ReportTaskSucceededResponseBody(name='body'),
}

/**
 * @summary Reports a successful task.
 *
 * @description ## [](#)Usage notes
 * In the previous service (Serverless Workflow), the task step that ReportTaskSucceeded is used to call back pattern: waitForCallback indicates that the current task is successfully executed.
 * In the new service (CloudFlow), the task step that ReportTaskSucceeded is used to call back TaskMode: WaitForCustomCallback indicates that the current task is successfully executed.
 *
 * @param request ReportTaskSucceededRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ReportTaskSucceededResponse
 */
async function reportTaskSucceededWithOptions(request: ReportTaskSucceededRequest, runtime: $RuntimeOptions): ReportTaskSucceededResponse {
  request.validate();
  var query = {};
  if (!$isNull(request.taskToken)) {
    query['TaskToken'] = request.taskToken;
  }
  var body : map[string]any = {};
  if (!$isNull(request.output)) {
    body['Output'] = request.output;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'ReportTaskSucceeded',
    version = '2019-03-15',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Reports a successful task.
 *
 * @description ## [](#)Usage notes
 * In the previous service (Serverless Workflow), the task step that ReportTaskSucceeded is used to call back pattern: waitForCallback indicates that the current task is successfully executed.
 * In the new service (CloudFlow), the task step that ReportTaskSucceeded is used to call back TaskMode: WaitForCustomCallback indicates that the current task is successfully executed.
 *
 * @param request ReportTaskSucceededRequest
 * @return ReportTaskSucceededResponse
 */
async function reportTaskSucceeded(request: ReportTaskSucceededRequest): ReportTaskSucceededResponse {
  var runtime = new $RuntimeOptions{};
  return reportTaskSucceededWithOptions(request, runtime);
}

model StartExecutionRequest {
  callbackFnFTaskToken?: string(name='CallbackFnFTaskToken', description='Specifies that the **TaskToken**-related tasks are called back after the execution in the flow ends.', example='12'),
  executionName?: string(name='ExecutionName', description='The name of the execution. The execution name is unique within a workflow. Configure this parameter based on the following rules:

*   The name must start with a letter or an underscore (_).
*   The name can contain letters, digits, underscores (_), and hyphens (-).
*   The name is case-sensitive.
*   The name must be 1 to 128 characters in length.', example='exec'),
  flowName?: string(name='FlowName', description='The name of the workflow to be executed.

This parameter is required.', example='flow'),
  input?: string(name='Input', description='The input of the execution, which is in the JSON format.', example='{"key":"value"}'),
}

model StartExecutionResponseBody = {
  flowDefinition?: string(name='FlowDefinition', description='The definition of the flow.', example='version: v1.0\\\\ntype: flow\\\\nname: test\\\\nsteps:\\\\n - type: pass\\\\n name: mypass'),
  flowName?: string(name='FlowName', description='The name of the workflow.', example='flow'),
  input?: string(name='Input', description='The input of the execution, which is in the JSON format.', example='{"key":"value"}'),
  name?: string(name='Name', description='The name of the execution.', example='exec1'),
  output?: string(name='Output', description='The execution result, which is in the JSON format.', example='{"key":"value"}'),
  requestId?: string(name='RequestId', description='The request ID.', example='testRequestId'),
  startedTime?: string(name='StartedTime', description='The time when the execution started.', example='2019-01-01T01:01:01.001Z'),
  status?: string(name='Status', description='The execution status. Valid values:

*   **Starting**
*   **Running**
*   **Stopped**
*   **Succeeded**
*   **Failed**
*   **TimedOut**', example='Succeeded'),
  stoppedTime?: string(name='StoppedTime', description='The time when the execution stopped.', example='2019-01-01T01:01:01.001Z'),
}

model StartExecutionResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: StartExecutionResponseBody(name='body'),
}

/**
 * @summary Starts the execution of a workflow.
 *
 * @description ## [](#)Usage notes
 * *   The flow is created. A flow only in standard mode is supported.
 * *   If you do not specify an execution, the system automatically generates an execution and starts the execution.
 * *   If an ongoing execution has the same name as that of the execution to be started, the system directly returns the ongoing execution.
 * *   If the ongoing execution with the same name has ended (succeeded or failed), `ExecutionAlreadyExists` is returned.
 * *   If no execution with the same name exists, the system starts a new execution.
 *
 * @param request StartExecutionRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return StartExecutionResponse
 */
async function startExecutionWithOptions(request: StartExecutionRequest, runtime: $RuntimeOptions): StartExecutionResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.callbackFnFTaskToken)) {
    body['CallbackFnFTaskToken'] = request.callbackFnFTaskToken;
  }
  if (!$isNull(request.executionName)) {
    body['ExecutionName'] = request.executionName;
  }
  if (!$isNull(request.flowName)) {
    body['FlowName'] = request.flowName;
  }
  if (!$isNull(request.input)) {
    body['Input'] = request.input;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'StartExecution',
    version = '2019-03-15',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Starts the execution of a workflow.
 *
 * @description ## [](#)Usage notes
 * *   The flow is created. A flow only in standard mode is supported.
 * *   If you do not specify an execution, the system automatically generates an execution and starts the execution.
 * *   If an ongoing execution has the same name as that of the execution to be started, the system directly returns the ongoing execution.
 * *   If the ongoing execution with the same name has ended (succeeded or failed), `ExecutionAlreadyExists` is returned.
 * *   If no execution with the same name exists, the system starts a new execution.
 *
 * @param request StartExecutionRequest
 * @return StartExecutionResponse
 */
async function startExecution(request: StartExecutionRequest): StartExecutionResponse {
  var runtime = new $RuntimeOptions{};
  return startExecutionWithOptions(request, runtime);
}

model StartSyncExecutionRequest {
  executionName?: string(name='ExecutionName', description='The name of the execution that you want to start. The name must meet the following conventions:

*   The name can contain letters, digits, underscores (_), and hyphens (-).
*   The name must start with a letter or an underscore (_).
*   The name is case-sensitive.
*   The name must be 1 to 128 characters in length.

Different from the StartExecution operation, in the synchronous execution mode, the execution name is no longer required to be unique within a flow. You can choose to provide an execution name to identify the current execution. In this case, the system adds a UUID to the current execution name. The used format is {ExecutionName}:{UUID}. If you do not specify the execution name, the system automatically generates an execution name.', example='my_exec_name'),
  flowName?: string(name='FlowName', description='The name of the workflow to be executed.

This parameter is required.', example='my_flow_name'),
  input?: string(name='Input', description='The input of the execution, which is in the JSON format.', example='{"key":"value"}'),
}

model StartSyncExecutionResponseBody = {
  errorCode?: string(name='ErrorCode', description='The error code that is returned if the execution failed.', example='ActionNotSupported'),
  errorMessage?: string(name='ErrorMessage', description='The error message that indicates the execution timed out.', example='Standard execution is not supported'),
  flowName?: string(name='FlowName', description='The name of the flow.', example='my_flow_name'),
  name?: string(name='Name', description='The name of the execution.', example='my_exec_name:{UUID}'),
  output?: string(name='Output', description='The output of the execution, which is in the JSON format.', example='{"key":"value"}'),
  requestId?: string(name='RequestId', description='The request ID.', example='testRequestId'),
  startedTime?: string(name='StartedTime', description='The time when the execution started.', example='2019-01-01T01:01:01.001Z'),
  status?: string(name='Status', description='The status of the execution. Valid values:

*   **Starting**
*   **Running**
*   **Stopped**
*   **Succeeded**
*   **Failed**
*   **TimedOut**', example='Succeeded'),
  stoppedTime?: string(name='StoppedTime', description='The time when the execution stopped.', example='2019-01-01T01:01:01.001Z'),
}

model StartSyncExecutionResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: StartSyncExecutionResponseBody(name='body'),
}

/**
 * @summary Synchronously starts an execution in a flow.
 *
 * @description *   Only flows of the express execution mode are supported.
 *
 * @param request StartSyncExecutionRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return StartSyncExecutionResponse
 */
async function startSyncExecutionWithOptions(request: StartSyncExecutionRequest, runtime: $RuntimeOptions): StartSyncExecutionResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.executionName)) {
    body['ExecutionName'] = request.executionName;
  }
  if (!$isNull(request.flowName)) {
    body['FlowName'] = request.flowName;
  }
  if (!$isNull(request.input)) {
    body['Input'] = request.input;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'StartSyncExecution',
    version = '2019-03-15',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Synchronously starts an execution in a flow.
 *
 * @description *   Only flows of the express execution mode are supported.
 *
 * @param request StartSyncExecutionRequest
 * @return StartSyncExecutionResponse
 */
async function startSyncExecution(request: StartSyncExecutionRequest): StartSyncExecutionResponse {
  var runtime = new $RuntimeOptions{};
  return startSyncExecutionWithOptions(request, runtime);
}

model StopExecutionRequest {
  cause?: string(name='Cause', description='The reason for stopping the execution. The value must be 1 to 4,096 characters in length.', example='for test'),
  error?: string(name='Error', description='The error code for stopping the execution. The error code must be 1 to 128 characters in length.', example='nill'),
  executionName?: string(name='ExecutionName', description='The name of the execution to be stopped. You can call the **ListExecutions** operation to obtain the value of this parameter.

This parameter is required.', example='exec'),
  flowName?: string(name='FlowName', description='The name of the workflow to be stopped. You can call the **ListFlows** operation to obtain the value of this parameter.

This parameter is required.', example='flow'),
}

model StopExecutionResponseBody = {
  flowDefinition?: string(name='FlowDefinition', description='The definition of the flow.', example='version: v1.0\\\\ntype: flow\\\\nname: test\\\\nsteps:\\\\n - type: pass\\\\n name: mypass'),
  flowName?: string(name='FlowName', description='The name of the flow.', example='flow'),
  input?: string(name='Input', description='The input of the execution, which is in the JSON format.', example='{"key":"value"}'),
  name?: string(name='Name', description='The name of the execution.', example='exec'),
  output?: string(name='Output', description='The execution result, which is in the JSON format.', example='{"key":"value"}'),
  requestId?: string(name='RequestId', description='The request ID.', example='testRequestId'),
  roleArn?: string(name='RoleArn', description='执行的角色权限配置。若流程定义中的RoleArn在执行期间发生变更，系统将记录并返回执行初始时刻的RoleArn的快照。
> 如果您的流程在执行时未配置执行角色，则该字段不会出现。', example='acs:ram:${region}:${accountID}:${role}'),
  startedTime?: string(name='StartedTime', description='The time when the execution started.', example='2019-01-01T01:01:01.001Z'),
  status?: string(name='Status', description='The execution status. Valid values:

*   **Starting**
*   **Running**
*   **Stopped**
*   **Succeeded**
*   **Failed**
*   **TimedOut**', example='Running'),
  stoppedTime?: string(name='StoppedTime', description='The time when the execution stopped.', example='2019-01-01T01:01:01.001Z'),
}

model StopExecutionResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: StopExecutionResponseBody(name='body'),
}

/**
 * @summary Stops an execution that is in progress in a flow.
 *
 * @description ## [](#)Usage notes
 * The flow must be in progress.
 *
 * @param request StopExecutionRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return StopExecutionResponse
 */
async function stopExecutionWithOptions(request: StopExecutionRequest, runtime: $RuntimeOptions): StopExecutionResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.cause)) {
    body['Cause'] = request.cause;
  }
  if (!$isNull(request.error)) {
    body['Error'] = request.error;
  }
  if (!$isNull(request.executionName)) {
    body['ExecutionName'] = request.executionName;
  }
  if (!$isNull(request.flowName)) {
    body['FlowName'] = request.flowName;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'StopExecution',
    version = '2019-03-15',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Stops an execution that is in progress in a flow.
 *
 * @description ## [](#)Usage notes
 * The flow must be in progress.
 *
 * @param request StopExecutionRequest
 * @return StopExecutionResponse
 */
async function stopExecution(request: StopExecutionRequest): StopExecutionResponse {
  var runtime = new $RuntimeOptions{};
  return stopExecutionWithOptions(request, runtime);
}

model UpdateFlowRequest {
  definition?: string(name='Definition', description='The definition of the workflow. The definition must comply with the flow definition language (FDL) syntax. Considering compatibility, the system supports the two workflow definition specifications.

>  In the preceding workflow definition example, Name:my_flow_name is the workflow name, which must be consistent with the input parameter Name', example='version: v1.0\\\\ntype: flow\\\\nname: test\\\\nsteps:\\\\n  - type: pass\\\\n    name: mypass'),
  description?: string(name='Description', description='The description of the flow.', example='test definition'),
  name?: string(name='Name', description='The name of the workflow.

This parameter is required.', example='flow'),
  roleArn?: string(name='RoleArn', description='The Alibaba Cloud resource name (ARN) of the authorized role on which the execution of the flow relies. During the execution of the flow, the flow execution engine assumes the role to call API operations of relevant services.', example='acs:ram::${accountID}:${role}'),
  type?: string(name='Type', description='The type of the flow. Valid value: **FDL**.', example='FDL'),
}

model UpdateFlowResponseBody = {
  createdTime?: string(name='CreatedTime', description='The time when the flow was created.', example='2019-01-01T01:01:01.001Z'),
  definition?: string(name='Definition', description='The flow definition, which follows the FDL syntax standard. Considering compatibility, the system supports the two flow definition specifications.', example='version: v1.0\\\\ntype: flow\\\\nname: test\\\\nsteps:\\\\n  - type: pass\\\\n    name: mypass'),
  description?: string(name='Description', description='The description of the flow.', example='test definition'),
  externalStorageLocation?: string(name='ExternalStorageLocation', description='The path of the external storage.', example='/path'),
  id?: string(name='Id', description='The unique ID of the flow.', example='e589e092-e2c0-4dee-b306-3574ddfdddf5****'),
  lastModifiedTime?: string(name='LastModifiedTime', description='The time when the flow was last modified.', example='2019-01-01T01:01:01.001Z'),
  name?: string(name='Name', description='The name of the flow.', example='flow'),
  requestId?: string(name='RequestId', description='The request ID.', example='testRequestID'),
  roleArn?: string(name='RoleArn', description='The Alibaba Cloud resource name (ARN) of the authorized role on which the execution of the flow relies. During the execution of the flow, the flow execution engine assumes the role to call API operations of relevant services.', example='acs:ram::${accountID}:${role}'),
  type?: string(name='Type', description='The type of the flow.', example='FDL'),
}

model UpdateFlowResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: UpdateFlowResponseBody(name='body'),
}

/**
 * @summary Updates a flow.
 *
 * @param request UpdateFlowRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return UpdateFlowResponse
 */
async function updateFlowWithOptions(request: UpdateFlowRequest, runtime: $RuntimeOptions): UpdateFlowResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.definition)) {
    body['Definition'] = request.definition;
  }
  if (!$isNull(request.description)) {
    body['Description'] = request.description;
  }
  if (!$isNull(request.name)) {
    body['Name'] = request.name;
  }
  if (!$isNull(request.roleArn)) {
    body['RoleArn'] = request.roleArn;
  }
  if (!$isNull(request.type)) {
    body['Type'] = request.type;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'UpdateFlow',
    version = '2019-03-15',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Updates a flow.
 *
 * @param request UpdateFlowRequest
 * @return UpdateFlowResponse
 */
async function updateFlow(request: UpdateFlowRequest): UpdateFlowResponse {
  var runtime = new $RuntimeOptions{};
  return updateFlowWithOptions(request, runtime);
}

model UpdateScheduleRequest {
  cronExpression?: string(name='CronExpression', description='The CRON expression.', example='0 * * * * *'),
  description?: string(name='Description', description='The description of the time-based schedule.', example='test description'),
  enable?: boolean(name='Enable', description='Specifies whether to enable the time-based schedule. Valid values:

*   **true**
*   **false**', example='true'),
  flowName?: string(name='FlowName', description='The name of the flow that is associated with the time-based schedule. The name must be unique within the region and cannot be modified after the time-based schedule is created. The name must meet the following conventions:

*   The name can contain letters, digits, underscores (_), and hyphens (-).
*   The name must start with a letter or an underscore (_).
*   The name is case-sensitive.
*   The name must be 1 to 128 characters in length.

This parameter is required.', example='testFlowName'),
  payload?: string(name='Payload', description='The trigger message of the time-based schedule. It must be in the JSON format.', example='{"key": "value"}'),
  scheduleName?: string(name='ScheduleName', description='The name of the time-based schedule. The name must meet the following conventions:

*   The name can contain letters, digits, underscores (_), and hyphens (-).
*   The name must start with a letter or an underscore (_).
*   The name is case-sensitive.
*   The name must be 1 to 128 characters in length.

This parameter is required.', example='testScheduleName'),
}

model UpdateScheduleResponseBody = {
  createdTime?: string(name='CreatedTime', description='The time when the time-based schedule was created.', example='2020-01-01T01:01:01.001Z'),
  cronExpression?: string(name='CronExpression', description='The CRON expression.', example='0 * * * * *'),
  description?: string(name='Description', description='The description of the time-based schedule.', example='test description'),
  enable?: boolean(name='Enable', description='Indicates whether the time-based schedule is enabled. Valid values:

*   **true**
*   **false**', example='true'),
  lastModifiedTime?: string(name='LastModifiedTime', description='The time when the time-based schedule was last updated.', example='2020-01-01T01:01:01.001Z'),
  payload?: string(name='Payload', description='The trigger message of the time-based schedule.', example='{"key": "value"}'),
  requestId?: string(name='RequestId', description='The request ID.', example='testRequestId'),
  scheduleId?: string(name='ScheduleId', description='The ID of the time-based schedule.', example='testScheduleId'),
  scheduleName?: string(name='ScheduleName', description='The name of the time-based schedule.', example='testScheduleName'),
}

model UpdateScheduleResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: UpdateScheduleResponseBody(name='body'),
}

/**
 * @summary Updates a time-based schedule.
 *
 * @param request UpdateScheduleRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return UpdateScheduleResponse
 */
async function updateScheduleWithOptions(request: UpdateScheduleRequest, runtime: $RuntimeOptions): UpdateScheduleResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.cronExpression)) {
    body['CronExpression'] = request.cronExpression;
  }
  if (!$isNull(request.description)) {
    body['Description'] = request.description;
  }
  if (!$isNull(request.enable)) {
    body['Enable'] = request.enable;
  }
  if (!$isNull(request.flowName)) {
    body['FlowName'] = request.flowName;
  }
  if (!$isNull(request.payload)) {
    body['Payload'] = request.payload;
  }
  if (!$isNull(request.scheduleName)) {
    body['ScheduleName'] = request.scheduleName;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'UpdateSchedule',
    version = '2019-03-15',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if ($isNull(@signatureVersion) || @signatureVersion != 'v4') {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Updates a time-based schedule.
 *
 * @param request UpdateScheduleRequest
 * @return UpdateScheduleResponse
 */
async function updateSchedule(request: UpdateScheduleRequest): UpdateScheduleResponse {
  var runtime = new $RuntimeOptions{};
  return updateScheduleWithOptions(request, runtime);
}

